import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import naive from 'naive-ui'
import { router } from "./common/router.js";
import { createPinia } from "pinia";
import axios from "axios";
import { AdminStore } from "./stores/AdminStore";
import { createDiscreteApi } from "naive-ui";

const { message, dialog } = createDiscreteApi(["message", "dialog"]);
axios.defaults.baseURL = "http://localhost:8000"

/* 
    axios
    pinia
    sass
    vue-router
    naive-ui
    wangeditor
*/

const app = createApp(App)


app.use(router)
app.use(naive)
app.use(createPinia())

app.provide('axios', axios)
app.provide('message', message)
app.provide('dialog', dialog)
app.provide('serverUrl', axios.defaults.baseURL)

const adminStore = AdminStore()
// adminStore.token = localStorage.getItem("token")
axios.interceptors.request.use((config) => {
    config.headers.token = localStorage.getItem("token")
    return config
})

app.mount('#app')
